list-[id].vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <!-- 头部 -->
  3. <templateHead></templateHead>
  4. <!-- 菜单 -->
  5. <templateMenu></templateMenu>
  6. <!-- 内容 -->
  7. <div v-for="(item,index) in templateData" :key="index">
  8. <!--广告组件-->
  9. <templateAd :skinId="skinId" :adData="adData" :adTag="item.ad.ad_tag" v-if="item.sectorName=='adSector'"></templateAd>
  10. <!--列表组件-->
  11. <templateList :skinId="skinId" :templateData="item.componentList" :routeId="routeId" :pageData="pageData" :newsList="newsList" v-if="item.sectorName=='fixedListSector'"></templateList>
  12. </div>
  13. <!-- 底部 -->
  14. <templateFoot></templateFoot>
  15. </template>
  16. <script setup>
  17. //0.加载全局模板组件 start---------------------------------------->
  18. //0.1全局通栏
  19. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  20. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  21. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  22. //0.2局部通栏
  23. //0.2.1广告组件
  24. import templateAd from '@/components/template/sector/body/ad/1200x90/1.vue'
  25. //0.2.2列表组件
  26. import templateList from '@/components/template/sector/body/list/list/1200x1220/1.vue'
  27. //0.加载全局模板组件 end---------------------------------------->
  28. //1.获得基本信息单元 start---------------------------------------->
  29. //1.1获得页面依赖
  30. import { ref, onMounted } from 'vue';
  31. //1.2使用url查询导航池id
  32. const targetSegment = getRoutePath(1);//当前页面的url路径 这是第一层 所以获得域名后面的第一层url
  33. const routeId = ref("");//当前url路径代表的cid
  34. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  35. method: 'GET',
  36. query: {
  37. 'pinyin': targetSegment,
  38. },
  39. });
  40. if (getRouteId.code == 200) {
  41. routeId.value = getRouteId.data.category_id
  42. }
  43. //1.3获得pinia源
  44. import { useTemplateBaseStore } from '@/stores/templateBase'
  45. const templateBaseStore = useTemplateBaseStore()
  46. //1.4获得该页的皮肤id - 在每个组件中也是同样的获得方法
  47. const skinId = ref("")
  48. const websiteId = ref("")
  49. //1.5获得站点基本信息
  50. const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
  51. method: 'GET',
  52. query: {
  53. 'link_textnum':24,
  54. 'link_imgnum':18,
  55. 'link_footnum':4
  56. },
  57. });
  58. if (responseStatus.code == 200) {
  59. //1.6.1设置站点基本信息
  60. templateBaseStore.setWebSiteInfo(responseStatus.data)
  61. websiteId.value = responseStatus.data.website_head.id;//获得网站id
  62. //1.6.2设置皮肤id
  63. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  64. }
  65. //1.6.seo
  66. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  67. method: 'GET',
  68. query: {
  69. 'catid': routeId.value
  70. },
  71. });
  72. let seoTitle = setData.data.seo_title;
  73. let seoDescription = setData.data.seo_description;
  74. let seoKeywords = setData.data.seo_keywords;
  75. let seoSuffix = setData.data.suffix;
  76. let seoName = setData.data.website_name;
  77. useSeoMeta({
  78. title: seoTitle + "_" + seoSuffix,
  79. meta: [
  80. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  81. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  82. ]
  83. });
  84. //1.获得基本信息单元 end---------------------------------------->
  85. //2.页面数据 start---------------------------------------->
  86. //2.1获得页面模板数据
  87. const response = await requestDataPromise('/client/indexData', {
  88. method: 'POST',
  89. body: {
  90. 'website_id':websiteId.value,
  91. 'getpage':'index'
  92. },
  93. });
  94. //页面模板数据
  95. const templateData = response.data.template.list;
  96. console.log(templateData)
  97. //2.2广告数据
  98. const adData = ref([]);
  99. adData.value.push(response.data.ad.top)
  100. for(let item of response.data.ad.list){
  101. adData.value.push(item)
  102. }
  103. templateBaseStore.setAdList(adData.value)
  104. //2.3分页数据
  105. const route = useRoute();
  106. let pageNum = ref(1); //当前页码
  107. pageNum.value = parseInt(route.params.id);//路由中传递的分页页码
  108. let total = ref(100); //总条数
  109. let pageSize = ref(20); //每页条数
  110. //3.1新闻列表数据
  111. const newsList = ref([]);
  112. let newslists = async () => {
  113. const listData = await requestDataPromise('/web/getWebsiteArticleList', {
  114. method: 'GET',
  115. query: {
  116. 'page': pageNum.value,
  117. 'pageSize': pageSize.value,
  118. 'catid': routeId.value
  119. },
  120. });
  121. console.log(listData)
  122. if (listData.code == 200) {
  123. newsList.value = listData.data.rows;
  124. pageData.value.total = listData.data.count;
  125. }
  126. }
  127. newslists();
  128. let pageData = ref({
  129. "pageNum": pageNum.value,
  130. "pageSize": pageSize.value,
  131. "total": total.value
  132. });
  133. //2.页面数据 end---------------------------------------->
  134. </script>
  135. <style lang="less" scoped>
  136. @import url('@/assets/css/list.less');
  137. </style>